$(document).ready(function () {
    /*展会列表
     *开始
     * */
    var pageNum = 1;
    var pageSize = 8;
    var tol = 1;
    var pageNum1 = 1;
    var pageSize1 = 8;
    //展会列表检索调用的方法的参数
    var data11 = {
        pageNum: pageNum1,
        pageSize: pageSize1
    };
    var flag = true;//判断当前页面是什么 true 展会列表 false 名片
    var flag1 = 0;//判断当前页面是否是名片详情页面 0 否 1 是
    //展会列表检索调用的方法
    function ajax1() {
        var data2 = new Array();//存储所有数据
        var apd1 = new Array();//要添加的展会数据
        $('#zhanhui').empty();//清空
        //判断展会检索信息的页数
        $.ajax({
            url: "http://www.enet720.net:8080/zwkj/exhibition/findByterm",
            type: "POST",
            dataType: "json",
            data: JSON.stringify(data11),
            async: false,//同步请求
            contentType: "application/json;charset=utf-8",
            timeout: 5000,
            success: function (data) {
                //判断是否获取数据成功
                if (data.code == "0") {
                    if (data.data.total > 0) {
                        tol = Math.ceil(data.data.total / 8);
                        //判断 如果不够一页8条数据，分页底部还是一页
                        if (tol === 0) {
                            tol = 1;
                        }
                    } else {
                        $("#zhanhui").append("抱歉，暂无该展会数据！嘿嘿嘿........请重新查找！<a href='../HTML/exhibit-list.html'\">返回到展会列表</a>。。。");
                    }
                } else {
                    alert("数据异常请重试!");
                }
            },
            error: function () {
                alert("请求超时请重试！");
            }
        });
        //添加展会数据
        $.jqPaginator('#pagination', {
            totalPages: tol,
            visiblePages: 10,
            currentPage: 1,
            wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num) {
                if (num > 0) {
                    pageNum1 = num;
                    data11 = {
                        "pageNum": pageNum1,
                        "pageSize": pageSize1,
                        "ehName": coun,
                        "ehCity": coun1,
                        "ehYear": coun2,
                        "ehMonth": coun3,
                        "style": coun4
                    };
                    $.ajax({
                        url: "http://www.enet720.net:8080/zwkj/exhibition/findByterm",
                        type: "POST",
                        dataType: "json",
                        data: JSON.stringify(data11),
                        async: false,//同步请求
                        contentType: "application/json;charset=utf-8",
                        timeout: 5000,
                        success: function (data) {
                            if (data.code === 0) {
                                if (data.data.total > 0) {
                                    var data1 = {
                                        "accId": sessionStorage.phone
                                    };
                                    apd1.splice(0, apd1.length);
                                    data2.splice(0, data2.length);
                                    for (var n1 = 0; n1 < data.data.list.length; n1++) {
                                        apd1.push("<div class='col-xs-12 col-sm-6 col-md-4 col-lg-3' id='" + n1 + "' name='" + data.data.list[n1].exhibitionId + "'>\n" +
                                            "                <div class='exhibition_list'>\n" +
                                            "                    <div class='list-title'>\n" +
                                            "                        <span title='" + data.data.list[n1].exhibitionName + "'>" + data.data.list[n1].exhibitionName + "</span>\n" +
                                            "                    </div>\n" +
                                            "                    <div class='list-content'>\n" +
                                            "                        <span class='list-content-title' title='" + data.data.list[n1].exhibitionHall + "'>\n" +
                                            "                        ---" + data.data.list[n1].exhibitionHall + "\n" +
                                            "                        </span>\n" +
                                            "                    </div>\n" +
                                            "                    <div class='exhibition-style' title='" + data.data.list[n1].exhibitionStyle + "'>行业分类 - " + data.data.list[n1].exhibitionStyle + "</div>\n" +
                                            "                    <div class='div-Radius'></div>\n" +
                                            "                    <span class='list-span' title='" + data.data.list[n1].exhibitionPrice + "'>" + data.data.list[n1].exhibitionPrice + "</span>\n" +
                                            "                    <span class='list-time-a'></span>\n" +
                                            "                    <span class='list-time-b' title='" + data.data.list[n1].exhibitionStart + "---" + data.data.list[n1].exhibitionEnd + "'>" + data.data.list[n1].exhibitionStart + "---" + data.data.list[n1].exhibitionEnd + "</span>\n" +
                                            "                    <a href='../HTML/merchant-exh.html?exhibitionId=" + data.data.list[n1].exhibitionId + "&exhibitionName=" + data.data.list[n1].exhibitionName + "' class='list-number'>" + data.data.list[n1].exhibitionMerchantCount + "位展商</a>\n" +
                                            "                    <div class='list-collect' name='lol'></div><span class='list-collect-span'>未收藏</span>\n" +
                                            "                </div>\n" +
                                            "            </div>");
                                        data2.push(data.data.list[n1]);
                                    }
                                    //判断是否当前用户收藏
                                    $.ajax({
                                        url: "http://www.enet720.net:8080/zwkj/exhibition/findBytransalte",
                                        type: "POST",
                                        dataType: "json",
                                        data: JSON.stringify(data1),
                                        async: false,//同步请求
                                        contentType: "application/json;charset=utf-8",
                                        timeout: 5000,
                                        success: function (data1) {
                                            if (data1.code == "0") {
                                                for (var n2 = 0; n2 < data1.data.list.length; n2++) {
                                                    for (var i = 0; i < data2.length; i++) {
                                                        if (data2[i].exhibitionId === data1.data.list[n2].exhibitionId) {
                                                            for (var j = 0; j < apd1.length; j++) {
                                                                if (i == j) {
                                                                    apd1[j] = "<div class='col-xs-12 col-sm-6 col-md-4 col-lg-3' id='" + j + "' name='" + data2[i].exhibitionId + "'>\n" +
                                                                        "                <div class='exhibition_list'>\n" +
                                                                        "                    <div class='list-title'>\n" +
                                                                        "                        <span title='" + data2[i].exhibitionName + "'>" + data2[i].exhibitionName + "</span>\n" +
                                                                        "                    </div>\n" +
                                                                        "                    <div class='list-content'>\n" +
                                                                        "                        <span class='list-content-title' title='" + data2[i].exhibitionHall + "'>\n" +
                                                                        "                        ---" + data2[i].exhibitionHall + "\n" +
                                                                        "                        </span>\n" +
                                                                        "                    </div>\n" +
                                                                        "                    <div class='exhibition-style' title='" + data2[i].exhibitionStyle + "'>行业分类 - " + data2[i].exhibitionStyle + "</div>\n" +
                                                                        "                    <div class='div-Radius'></div>\n" +
                                                                        "                    <span class='list-span' title='" + data2[i].exhibitionPrice + "'>" + data2[i].exhibitionPrice + "</span>\n" +
                                                                        "                    <span class='list-time-a'></span>\n" +
                                                                        "                    <span class='list-time-b' title='" + data2[i].exhibitionStart + "---" + data2[i].exhibitionEnd + "'>" + data2[i].exhibitionStart + "---" + data2[i].exhibitionEnd + "</span>\n" +
                                                                        "                    <a href='../HTML/merchant-exh.html?exhibitionId=" + data2[i].exhibitionId + "&exhibitionName=" + data2[i].exhibitionName + "' class='list-number'>" + data2[i].exhibitionMerchantCount + "位展商</a>\n" +
                                                                        "                    <div class='list-collect1' name='lol'></div><span class='list-collect-span'>已收藏</span>\n" +
                                                                        "                </div>\n" +
                                                                        "            </div>";
                                                                }
                                                            }

                                                        }
                                                    }
                                                }
                                                $('#zhanhui').empty();
                                                $('#zhanhui').append(apd1);
                                            }
                                        },
                                        error: function () {
                                            alert("请求超时请重试！");
                                        }
                                    });
                                } else {
                                    $("#zhanhui").append("抱歉，暂无该展会数据！嘿嘿嘿........请重新查找！<a href='../HTML/exhibit-list.html'\">返回到展会列表</a>。。。");
                                }
                            } else {
                                alert("数据异常请重试!");
                            }
                        },
                        error: function () {
                            alert("请求超时请重试！");
                        }
                    });
                }
            }
        });
    }

    //加载展会信息的参数
    var data = {
        "pageNum": pageNum,
        "pageSize": pageSize
    };
    var data2 = new Array();//存储展会数据
    var apd1 = new Array();//要添加的展会数据
    var data3 = {};//收藏的参数
    //点击展会列表进入展会列表页面
    $("#list-e").click(function () {
        $("#exh-card").css("display", "none");
        $("#exh-cont").css("display", "block");
        $("#list-e").attr("class", "btn-exh-list-ex");
        $("#card-e").attr("class", "btn-exh-list-car");
        $("#seek-input").css("display", "block");
        $("#seek-input").val("");
        $("#seek-input1").css("display", "none");
        $("#seek-input1").val("");
        if (!flag) {
            $(".li-screen").css("display", "block");
            flag = true;
        }
        flag1 = 0;
        zhanhui();
    });
    //点击收藏进行取消
    $("body").on("click", ".list-collect1", function () {
        var a = $(this);
        for (var i = 0; i < apd1.length; i++) {
            if (i == a.parent().parent().attr("id")) {
                data3 = {
                    "accId": sessionStorage.phone,
                    "ehbId": a.parent().parent().attr("name")
                };
            }
        }
        $.ajax({
            url: "http://www.enet720.net:8080/zwkj/exhibition/translate",
            type: "POST",
            dataType: "json",
            data: JSON.stringify(data3),
            async: true,//异步请求
            contentType: "application/json;charset=utf-8",
            timeout: 5000,
            success: function (data) {
                console.log(JSON.stringify(data));
                if (data.code == 0) {
                    a.attr("class", "list-collect");
                    a.next().text("未收藏");
                } else {
                    alert("系统繁忙请重试！");
                }
            },
            error: function () {
                alert("请求超时请重试！");
            }
        });
    });
    //点击收藏进行收藏
    $("body").on("click", ".list-collect", function () {
        var a = $(this);
        for (var i = 0; i < apd1.length; i++) {
            if (i == a.parent().parent().attr("id")) {
                data3 = {
                    "accId": sessionStorage.phone,
                    "ehbId": a.parent().parent().attr("name")
                };
            }
        }
        $.ajax({
            url: "http://www.enet720.net:8080/zwkj/exhibition/translate",
            type: "POST",
            dataType: "json",
            data: JSON.stringify(data3),
            async: true,//异步请求
            contentType: "application/json;charset=utf-8",
            timeout: 5000,
            success: function (data) {
                if (data.code == 0) {
                    a.attr("class", "list-collect1");
                    a.next().text("已收藏");
                    ft = true;
                } else {
                    alert("系统繁忙请重试！");
                }
            },
            error: function () {
                alert("请求超时请重试！");
            }
        });
    });
    var coun1 = null;//城市名称
    var coun2 = null;//年份
    var coun3 = null;//月份
    var coun4 = null;//行业名称
    var coun = null;//展会关键词
    //国家的检索
    $("a[name='country']").click(function () {
        var coun = $(this).text().toString();
        $("#ctry").text(coun);
    });
    //城市的检索
    $("a[name='urban']").click(function () {
        coun1 = $(this).text().toString();
        if (coun1 == "其他") {
            coun1 = null;
            data11 = {
                "ehName": coun,
                "ehCity": coun1,
                "ehYear": coun2,
                "ehMonth": coun3,
                "style": coun4
            };
            coun1 = "城市"
        }
        ajax1();
        $("#polis").text(coun1);
    });
    //行业的检索
    $("a[name='urban1']").click(function () {
        coun4 = $(this).text().toString();
        $("#polis1").text(coun4);
        if (coun4 == "其他") {
            coun4 = null
        }
        data11 = {
            "ehName": coun,
            "ehCity": coun1,
            "ehYear": coun2,
            "ehMonth": coun3,
            "style": coun4
        };
        ajax1();
    });
    //年份的检索
    $("a[name='year']").click(function () {
        var coun = $(this).text().toString();
        $("#vintage").text(coun);
        coun2 = $(this).text().replace("年", "").toString();
        data11 = {
            "ehName": coun,
            "ehCity": coun1,
            "ehYear": coun2,
            "ehMonth": coun3,
            "style": coun4
        };
        ajax1();
    });
    //月份的检索
    $("a[name='may']").click(function () {
        var coun = $(this).text().toString();
        $("#month").text(coun);
        coun3 = $(this).text().replace("月", "").toString();
        data11 = {
            "ehName": coun,
            "ehCity": coun1,
            "ehYear": coun2,
            "ehMonth": coun3,
            "style": coun4
        };
        ajax1();
    });
    //展会关键词的检索
    $("#seek-btn").click(function () {
        coun = $("#seek-input").val();
        data11 = {
            "ehName": coun,
            "ehCity": coun1,
            "ehYear": coun2,
            "ehMonth": coun3,
            "style": coun4
        };
        if (flag) {
            ajax1();
        } else {
            var catstr = {
                ehName: coun,
                pageNum: carpageNum,
                pageSize: carpageSize
            };
            ardList1(catstr);
            $.jqPaginator('#pagination', {
                totalPages: cartol,
                visiblePages: 10,
                currentPage: 1,
                wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
                first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
                prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
                next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
                last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
                page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
                onPageChange: function (num) {
                    if (num > 0) {
                        carpageNum = num;
                        catstr = {
                            ehName: coun,
                            pageNum: carpageNum,
                            pageSize: carpageSize
                        };
                        ardList1(catstr);
                    }
                }
            });
        }
        if (flag1 == 1) {
            //名片的公司关键词搜索
            var count = $("#seek-input1").val();
            var a = {
                mcCardName: count,
                pageNum: mppageNum,
                pageSize: mppageSize
            }
            ardList2(a);
            $('#pagination').jqPaginator('option', {
                totalPages: cartol,
                visiblePages: 10,
                currentPage: 1,
                wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
                first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
                prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
                next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
                last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
                page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
                onPageChange: function (num) {
                    if (num > 0) {
                        mppageNum = num;
                        a = {
                            mcCardName: count,
                            pageNum: mppageNum,
                            pageSize: mppageSize
                        };
                        ardList2(a);
                    }
                }
            });
        }
    })
    var datajson1 = {};//添加订单的参数
    //单个会刊的购买
    $('body').on("click", ".list-span", function () {
        datajson1 = {
            "accId": sessionStorage.phone,//用户id
            "mallId": $(this).parent().parent().attr("name")//展会id
        };
        var id = new Date().getTime();//订单id
        //添加订单
        $.ajax({
            type: "POST",
            url: "http://www.enet720.net:8080/zwkj/purchase/orders/exhibition/" + id + "",
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            async: false,
            data: JSON.stringify(datajson1),
            success: function (data) {
                console.log(JSON.stringify(data));
                if (data.code == "0") {
                    //查询订单
                    $.ajax({
                        type: "GET",
                        url: "http://www.enet720.net:8080/zwkj/purchase/orders/" + id + "",
                        contentType: 'application/json;charset=UTF-8',
                        dataType: 'json',
                        async: false,
                        success: function (data) {
                            if (data.code == "0") {
                                $("#iphone", parent.document).text(sessionStorage.phone);
                                $("#login_name", parent.document).text(sessionStorage.login_name);
                                $("#mall-id", parent.document).text(data.data.mallId);
                                $("#mall-name", parent.document).text(data.data.name);
                                $("#id", parent.document).text(data.data.id);
                                $("#mall-desc", parent.document).text(data.data.mallDesc);
                                $("#price", parent.document).text(data.data.price);
                                $("#order", parent.document).css("display", "block");
                                $(".shade", parent.document).css("display", "block");
                            } else {
                                alert("数据异常请重试！");
                            }
                        },
                        error: function () {
                            alert("请求超时请重试!");
                        }
                    });
                }

            },
            error: function () {
                alert("出错了，抱歉！");
            }
        });
    });
    //判断展会所有信息的页数
    $.ajax({
        url: "http://www.enet720.net:8080/zwkj/exhibition/findAll",
        type: "POST",
        dataType: "json",
        data: JSON.stringify(data),
        async: false,//同步请求
        contentType: "application/json;charset=utf-8",
        timeout: 5000,
        success: function (data) {
            if (data.code === 0) {
                if (data.data.total > 0) {
                    tol = Math.ceil(data.data.total / 8);
                    //判断 如果不够一页8条数据，分页底部还是一页
                    if (tol === 0) {
                        tol = 1;
                    }
                } else {
                    $("#zhanhui").append("抱歉，暂无展会数据！嘿嘿嘿........请重新尝试！<a href='../HTML/exhibit-list.html'\">返回到展会列表</a>。。。");
                }
            } else {
                alert("数据异常请重试!");
            }
        },
        error: function () {
            alert("请求超时请重试！");
        }
    });

    //查看所有展会信息并进行分页
    function zhanhui() {
        $.jqPaginator('#pagination', {
            totalPages: tol,
            visiblePages: 10,
            currentPage: 1,
            wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num) {
                if (num > 0) {
                    pageNum = num;
                    data = {
                        "pageNum": pageNum,
                        "pageSize": pageSize
                    };
                    $.ajax({
                        url: "http://www.enet720.net:8080/zwkj/exhibition/findAll",
                        type: "POST",
                        dataType: "json",
                        data: JSON.stringify(data),
                        async: false,//同步请求
                        contentType: "application/json;charset=utf-8",
                        timeout: 5000,
                        success: function (data) {
                            if (data.code === 0) {
                                if (data.data.total > 0) {
                                    var data1 = {
                                        "accId": sessionStorage.phone
                                    };
                                    apd1.splice(0, apd1.length);
                                    data2.splice(0, data2.length);
                                    for (var n1 = 0; n1 < data.data.list.length; n1++) {
                                        apd1.push("<div class='col-xs-12 col-sm-6 col-md-4 col-lg-3' id='" + n1 + "' name='" + data.data.list[n1].exhibitionId + "'>\n" +
                                            "                <div class='exhibition_list'>\n" +
                                            "                    <div class='list-title'>\n" +
                                            "                        <span title='" + data.data.list[n1].exhibitionName + "'>" + data.data.list[n1].exhibitionName + "</span>\n" +
                                            "                    </div>\n" +
                                            "                    <div class='list-content'>\n" +
                                            "                        <span class='list-content-title' title='" + data.data.list[n1].exhibitionHall + "'>\n" +
                                            "                        ---" + data.data.list[n1].exhibitionHall + "\n" +
                                            "                        </span>\n" +
                                            "                    </div>\n" +
                                            "                    <div class='exhibition-style' title='" + data.data.list[n1].exhibitionStyle + "'>行业分类 - " + data.data.list[n1].exhibitionStyle + "</div>\n" +
                                            "                    <div class='div-Radius'></div>\n" +
                                            "                    <span class='list-span' title='" + data.data.list[n1].exhibitionPrice + "'>" + data.data.list[n1].exhibitionPrice + "</span>\n" +
                                            "                    <span class='list-time-a'></span>\n" +
                                            "                    <span class='list-time-b' title='" + data.data.list[n1].exhibitionStart + "---" + data.data.list[n1].exhibitionEnd + "'>" + data.data.list[n1].exhibitionStart + "---" + data.data.list[n1].exhibitionEnd + "</span>\n" +
                                            "                    <a href='../HTML/merchant-exh.html?exhibitionId=" + data.data.list[n1].exhibitionId + "&exhibitionName=" + data.data.list[n1].exhibitionName + "' class='list-number'>" + data.data.list[n1].exhibitionMerchantCount + "位展商</a>\n" +
                                            "                    <div class='list-collect' name='lol'></div><span class='list-collect-span'>未收藏</span>\n" +
                                            "                </div>\n" +
                                            "            </div>");
                                        data2.push(data.data.list[n1]);
                                    }
                                    //判断是否当前用户收藏
                                    $.ajax({
                                        url: "http://www.enet720.net:8080/zwkj/exhibition/findBytransalte",
                                        type: "POST",
                                        dataType: "json",
                                        data: JSON.stringify(data1),
                                        async: false,//同步请求
                                        contentType: "application/json;charset=utf-8",
                                        timeout: 5000,
                                        success: function (data1) {
                                            if (data1.code == "0") {
                                                for (var n2 = 0; n2 < data1.data.list.length; n2++) {
                                                    for (var i = 0; i < data2.length; i++) {
                                                        if (data2[i].exhibitionId === data1.data.list[n2].exhibitionId) {
                                                            for (var j = 0; j < apd1.length; j++) {
                                                                if (i == j) {
                                                                    apd1[j] = "<div class='col-xs-12 col-sm-6 col-md-4 col-lg-3' id='" + j + "' name='" + data2[i].exhibitionId + "'>\n" +
                                                                        "                <div class='exhibition_list'>\n" +
                                                                        "                    <div class='list-title'>\n" +
                                                                        "                        <span title='" + data2[i].exhibitionName + "'>" + data2[i].exhibitionName + "</span>\n" +
                                                                        "                    </div>\n" +
                                                                        "                    <div class='list-content'>\n" +
                                                                        "                        <span class='list-content-title' title='" + data2[i].exhibitionHall + "'>\n" +
                                                                        "                        ---" + data2[i].exhibitionHall + "\n" +
                                                                        "                        </span>\n" +
                                                                        "                    </div>\n" +
                                                                        "                    <div class='exhibition-style' title='" + data2[i].exhibitionStyle + "'>行业分类 - " + data2[i].exhibitionStyle + "</div>\n" +
                                                                        "                    <div class='div-Radius'></div>\n" +
                                                                        "                    <span class='list-span' title='" + data2[i].exhibitionPrice + "'>" + data2[i].exhibitionPrice + "</span>\n" +
                                                                        "                    <span class='list-time-a'></span>\n" +
                                                                        "                    <span class='list-time-b' title='" + data2[i].exhibitionStart + "---" + data2[i].exhibitionEnd + "'>" + data2[i].exhibitionStart + "---" + data2[i].exhibitionEnd + "</span>\n" +
                                                                        "                    <a href='../HTML/merchant-exh.html?exhibitionId=" + data2[i].exhibitionId + "&exhibitionName=" + data2[i].exhibitionName + "' class='list-number'>" + data2[i].exhibitionMerchantCount + "位展商</a>\n" +
                                                                        "                    <div class='list-collect1' name='lol'></div><span class='list-collect-span'>已收藏</span>\n" +
                                                                        "                </div>\n" +
                                                                        "            </div>";
                                                                }
                                                            }

                                                        }
                                                    }
                                                }
                                                $('#zhanhui').empty();
                                                $('#zhanhui').append(apd1);
                                            }
                                        },
                                        error: function () {
                                            alert("请求超时请重试！");
                                        }
                                    });
                                } else {
                                    $("#zhanhui").append("抱歉，暂无展会数据！嘿嘿嘿........请重新尝试！<a href='../HTML/exhibit-list.html'\">返回到展会列表</a>。。。");
                                }
                            } else {
                                alert("数据异常请重试!");
                            }
                        },
                        error: function () {
                            alert("请求超时请重试！");
                        }
                    });
                }
            }
        });
    }

    window.load = zhanhui();
    /*展会列表
     *结束
     * */


    /**
     *  开始
     *  名片div操作
     * @type {number}
     */
    var carpageNum = 1;
    var carpageSize = 8;
    var cartol;
    var jspageNum = 1;
    var jspageSize = 8;
    var mppageNum = 1;
    var mppageSize = 8;
    //点击名片进入名片页面
    $("#card-e").click(function () {
        $("#exh-card").css("display", "block");
        $("#exh-cont").css("display", "none");
        $("#list-e").attr("class", "btn-exh-list-car");
        $("#card-e").attr("class", "btn-exh-list-ex");
        $("#exhcards").css("display", "none");
        $("#catexh").css("display", "block");
        $("#seek-input").val("");
        $("#seek-input").css("display", "block");
        $("#seek-input").val("");
        $("#seek-input1").css("display", "none");
        $("#seek-input1").val("");
        if (flag) {
            $(".li-screen").css("display", "none");
            flag = false;
        }
        flag1 = 0;
        ardList();
        $.jqPaginator('#pagination', {
            totalPages: cartol,
            visiblePages: 10,
            currentPage: 1,
            wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num) {
                if (num > 0) {
                    carpageNum = num;
                    ardList();
                }
            }
        });
        $("body").on("click", ".list-span2", function () {
            flag1 = 1;
            var id = $(this).parent().parent().attr("name"); //展会id
            $("#catexh").css("display", "none");
            $("#exhcards").css("display", "block");
            $("#seek-input1").css("display", "block");
            $("#seek-input").css("display", "none");
            var datajson = {
                ehId: id, //展会id
                pageNum: jspageNum,
                pageSize: jspageSize
            };
            idcardlist(datajson);
            $('#pagination').jqPaginator('option', {
                totalPages: cartol,
                visiblePages: 10,
                currentPage: 1,
                wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
                first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
                prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
                next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
                last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
                page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
                onPageChange: function (num) {
                    if (num > 0) {
                        jspageNum = num;
                        datajson = {
                            ehId: id, //展会id
                            pageNum: jspageNum,
                            pageSize: jspageSize
                        };
                        idcardlist(datajson);
                    }
                }
            });
        });
    });

//获取单个展会展商名片信息
    function idcardlist(str) {
        $("#exhcards").empty();
        $.ajax({
            type: "POST",
            url: "http://www.enet720.net:8080/zwkj/merchantcard/findAll",
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            async: false,
            data: JSON.stringify(str),
            success: function (data) {
                var d = data.data;
                // 如果数据查询成功，但是数据为空的判断处理
                if (d.total > 0) {
                    cartol = Math.ceil(d.total / 9);
                    if (cartol < 1) {
                        cartol = 1;
                    }
                    var list = d.list;
                    for (var i = 0; i < list.length; i++) {
                        $("#exhcards").append("  <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3 \">\n" +
                            "                <div class=\"exhibition_list\">\n" +
                            "                    <div class=\"list-car-content lis-b\">\n" +
                            "                          <ul>\n" +
                            "                              <li title='" + list[i].merchantCmName + "'><span>公司名称:</span>" + list[i].merchantCmName + "</li>\n" +
                            "                              <li title='" + list[i].merchantDties + "'><span>职务:</span>" + list[i].merchantDties + "</li>\n" +
                            "                              <li title='" + list[i].merchantName + "'><span>联系人:</span>" + list[i].merchantName + "</li>\n" +
                            "                              <li title='" + list[i].merchantPhone + "'><span>手机号:</span>" + list[i].merchantPhone + "</li>\n" +
                            "                              <li title='" + list[i].merchantFax + "'><span>传真:</span>" + list[i].merchantFax + "</li>\n" +
                            "                              <li title='" + list[i].merchantTelephone + "'><span>电话:</span>" + list[i].merchantTelephone + "</li>\n" +
                            "                          </ul>\n" +
                            "                    </div>\n" +
                            "                </div>\n" +
                            "            </div>");                        //---------------------------------------------------------------展商名片div-------------------------------------------------------明天代写-
                    }
                } else {
                    $("#exhcards").append("抱歉，暂无该展会名片数据！嘿嘿嘿........请从新查找！<a href='../HTML/exhibit-list.html'\">返回到展会列表</a>。。。");
                    cartol = 1;
                }
            },
            error: function () {
                alert("出错了,抱歉！")
            }
        });
    }

//获取所有展会信息
    function ardList() {
        var catstr = {
            pageNum: carpageNum,
            pageSize: carpageSize
        };
        $("#catexh").empty();
        $.ajax({
            type: "POST",
            url: "http://www.enet720.net:8080/zwkj/exhibition/findAll",
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            async: false,
            data: JSON.stringify(catstr),
            success: function (data) {
                var d = data.data;
                // 如果数据查询成功，但是数据为空的判断处理
                if (d.total > 0) {        //如果total有数据
                    cartol = Math.ceil(data.data.total / 8);
                    //判断 如果不够一页9条数据，分页底部还是一页
                    if (cartol === 0) {
                        cartol = 1;
                    }
                } else {                  //如果total没有数据出题的办法
                    $("#catexh").append("抱歉暂无数据！<a href='../HTML/exhibit-list.html'\\\">返回到展会列表</a>。。。\")");
                }

            },
            error: function () {
                alert("出错了,抱歉！")
            }
        });
        $.jqPaginator('#pagination', {
            totalPages: cartol,
            visiblePages: 10,
            currentPage: 1,
            wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num) {
                if (num > 0) {
                    carpageNum = num;
                    $.ajax({
                        type: "POST",
                        url: "http://www.enet720.net:8080/zwkj/exhibition/findAll",
                        contentType: 'application/json;charset=UTF-8',
                        dataType: 'json',
                        async: false,
                        data: JSON.stringify(catstr),
                        success: function (data) {
                            var d = data.data;
                            // 如果数据查询成功，但是数据为空的判断处理
                            if (d.total > 0) {        //如果total有数据
                                cartol = Math.ceil(data.data.total / 8);
                                //判断 如果不够一页9条数据，分页底部还是一页
                                if (cartol === 0) {
                                    cartol = 1;
                                }
                                var list = d.list;
                                for (var i = 0; i < list.length; i++) {
                                    $("#catexh").append("   <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3 \" name='" + list[i].exhibitionId + "'>\n" +
                                        "                <div class=\"exhibition_list\">\n" +
                                        "                    <div class=\"list-title\">\n" +
                                        "                        <span title='" + list[i].exhibitionName + "'>" + list[i].exhibitionName + "</span>\n" +
                                        "                    </div>\n" +
                                        "                    <div class=\"list-content\">\n" +
                                        "                        <span class=\"list-content-title\" title='" + list[i].exhibitionHall + "'>\n" +
                                        "                        ---" + list[i].exhibitionHall + "\n" +
                                        "                        </span>\n" +
                                        "                    </div>\n" +
                                        "                    <div class=\"div-Radius\"></div>\n" +
                                        "                    <span class=\"list-span2\">名片</span>\n" +
                                        "                </div>\n" +
                                        "            </div>");
                                }
                            } else {                  //如果total没有数据出题的办法
                                $("#catexh").append("抱歉暂无数据！<a href='../HTML/exhibit-list.html'\\\">返回到展会列表</a>。。。\")");
                            }

                        },
                        error: function () {
                            alert("出错了,抱歉！")
                        }
                    });
                }
            }
        });
    }

    //清空检索条件
    $("#polis").text("城市");
    $("#vintage").text("年份");
    $("#month").text("月份");
    $("#seek-input").val("");
    $("#seek-input1").val("");

    //根据展会关键词搜索名片信息
    function ardList1(catstr) {
        $("#catexh").empty();
        $.ajax({
            type: "POST",
            url: "http://www.enet720.net:8080/zwkj/exhibition/findByterm",
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            async: false,
            data: JSON.stringify(catstr),
            success: function (data) {
                var d = data.data;
                // 如果数据查询成功，但是数据为空的判断处理
                if (d.total > 0) {        //如果total有数据
                    cartol = Math.ceil(data.data.total / 8);
                    //判断 如果不够一页9条数据，分页底部还是一页
                    if (cartol === 0) {
                        cartol = 1;
                    }
                    var list = d.list;
                    for (var i = 0; i < list.length; i++) {
                        $("#catexh").append("   <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3 \" name='" + list[i].exhibitionId + "'>\n" +
                            "                <div class=\"exhibition_list\">\n" +
                            "                    <div class=\"list-title\">\n" +
                            "                        <span title='" + list[i].exhibitionName + "'>" + list[i].exhibitionName + "</span>\n" +
                            "                    </div>\n" +
                            "                    <div class=\"list-content\">\n" +
                            "                        <span class=\"list-content-title\" title='" + list[i].exhibitionHall + "'>\n" +
                            "                        ---" + list[i].exhibitionHall + "\n" +
                            "                        </span>\n" +
                            "                    </div>\n" +
                            "                    <div class=\"div-Radius\"></div>\n" +
                            "                    <span class=\"list-span2\">名片</span>\n" +
                            "                </div>\n" +
                            "            </div>");
                    }
                } else {                  //如果total没有数据出题的办法
                    $("#catexh").append("抱歉暂无数据！<a href='../HTML/exhibit-list.html'\\\">返回到展会列表</a>。。。\")");
                }

            },
            error: function () {
                alert("出错了,抱歉！");
            }
        });
    }

    //根据公司关键词搜索名片信息
    function ardList2(catstr) {
        $("#exhcards").empty();//清空当前内容
        $.ajax({
            type: "POST",
            url: "http://www.enet720.net:8080/zwkj/merchantcard/findByName",
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            async: false,
            data: JSON.stringify(catstr),
            success: function (data) {
                var d = data.data;
                // 如果数据查询成功，但是数据为空的判断处理
                if (d.total > 0) {
                    cartol = Math.ceil(d.total / 9);
                    if (cartol < 1) {
                        cartol = 1;
                    }
                    var list = d.list;
                    for (var i = 0; i < list.length; i++) {
                        $("#exhcards").append("  <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3 \">\n" +
                            "                <div class=\"exhibition_list\">\n" +
                            "                    <div class=\"list-car-content lis-b\">\n" +
                            "                          <ul>\n" +
                            "                              <li title='" + list[i].merchantCmName + "'><span>公司名称:</span>" + list[i].merchantCmName + "</li>\n" +
                            "                              <li title='" + list[i].merchantDties + "'><span>职务:</span>" + list[i].merchantDties + "</li>\n" +
                            "                              <li title='" + list[i].merchantName + "'><span>联系人:</span>" + list[i].merchantName + "</li>\n" +
                            "                              <li title='" + list[i].merchantPhone + "'><span>手机号:</span>" + list[i].merchantPhone + "</li>\n" +
                            "                              <li title='" + list[i].merchantFax + "'><span>传真:</span>" + list[i].merchantFax + "</li>\n" +
                            "                              <li title='" + list[i].merchantTelephone + "'><span>电话:</span>" + list[i].merchantTelephone + "</li>\n" +
                            "                          </ul>\n" +
                            "                    </div>\n" +
                            "                </div>\n" +
                            "            </div>");                        //---------------------------------------------------------------展商名片div-------------------------------------------------------明天代写-
                    }
                } else {
                    $("#exhcards").append("抱歉，暂无该展会名片数据！嘿嘿嘿........请从新查找！<a href='../HTML/exhibit-list.html'\">返回到展会列表</a>。。。");
                    cartol = 1;
                }

            },
            error: function () {
                alert("出错了,抱歉！");
            }
        });
    }

    /**
     *  结束
     *  名片div操作
     * @type {number}
     */

});